package day07;

import org.junit.jupiter.api.*;

class Demo01Test {



    //前置，用例前执行
    @BeforeEach //注解
    void setUp() {
        System.out.println("每个用例前执行");
    }

    //后置，用例后执行
    @AfterEach
    void tearDown() {
        System.out.println("每个用例后执行");
    }

    @BeforeAll
    static void func1(){
        System.out.println("所有用例前执行");
    }
    @AfterAll
    static void func2(){
        System.out.println("所有用例后执行");
    }
    //测试用例
    @Test
    void oct2dec() {
        System.out.println("最大值");
        int real = Demo01.oct2dec("77777");
        Assertions.assertEquals(32767, real);

        int real1 = Demo01.oct2dec("");
        Assertions.assertEquals(9999999, real1);

        int i = Demo01.oct2dec("0");
        Assertions.assertEquals(0, i);

        int real2 = Demo01.oct2dec("+7777");
        Assertions.assertEquals(4095, real2);

        int i1 = Demo01.oct2dec("-7777");
//        Assertions.assertEquals(-1, i1);

        int i2 = Demo01.oct2dec("8787");
        Assertions.assertEquals(9999999, i2);

        int i3 = Demo01.oct2dec(null);
        Assertions.assertEquals(9999999, i3);

        int i4 = Demo01.oct2dec("1234567");
        Assertions.assertEquals(9999999, i4);

    }
    @Test
    void oct3dec() {
        System.out.println("空字符串");
        int real1 = Demo01.oct2dec("");
        Assertions.assertEquals(9999999, real1);
    }
}